<template>
  <div>
    <van-nav-bar title="黑马优购" fixed>
      <div class="left_arrow" @click="()=>{ $router.go(-1) }" slot="left">
        <van-icon name="arrow-left" />
        <span>返回</span>
      </div>
    </van-nav-bar>
    <div class="list"></div>
    <van-row v-for="(item,index) in goodsList" :key="index" >
      <van-card
        :num="item.goods_number"
        :title="item.goods_name"
        :thumb="item.goods_small_logo"
        @click="$router.push(`/pages/goods_detail/:${item.goods_id}`)"
      >
        <template #tags>
          <van-tag type="danger" style="border:0">￥{{item.goods_price}}</van-tag>
        </template>
      </van-card>
    </van-row>
    <div class="nothing">没有更多了</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goodsList: []
    };
  },
  methods: {
    async getGoodsList() {
      const res = await this.$http.get("/goods/search", {
        params: this.$route.query
      });
      this.goodsList = res.message.goods;
    }
  },
  created() {
    this.getGoodsList();
  },
  computed: {
    goodsListLength: function() {
      if (this.goodsList.length == 0) {
        return false;
      } else {
        return true;
      }
    }
  }
};
</script>

<style lang="less" scoped>
.list {
  height: 55px;
}
.nothing {
  color: #969799;
  font-size: 14px;
  line-height: 50px;
  text-align: center;
}
</style>